var DataTypes = require("sequelize").DataTypes;
var _account = require("./account");
var _auth = require("./auth");
var _config_equip = require("./config_equip");
var _config_exp = require("./config_exp");
var _config_hero = require("./config_hero");
var _config_item = require("./config_item");
var _config_shop = require("./config_shop");
var _config_skill = require("./config_skill");
var _config_talent = require("./config_talent");
var _config_vip = require("./config_vip");
var _user = require("./user");
var _user_equip = require("./user_equip");
var _user_hero = require("./user_hero");
var _user_item = require("./user_item");
var _user_lineup = require("./user_lineup");
var _user_lineup_details = require("./user_lineup_details");
var _user_log_assets = require("./user_log_assets");
var _user_log_gold = require("./user_log_gold");
var _user_log_silver = require("./user_log_silver");

function initModels(sequelize) {
  var account = _account(sequelize, DataTypes);
  var auth = _auth(sequelize, DataTypes);
  var config_equip = _config_equip(sequelize, DataTypes);
  var config_exp = _config_exp(sequelize, DataTypes);
  var config_hero = _config_hero(sequelize, DataTypes);
  var config_item = _config_item(sequelize, DataTypes);
  var config_shop = _config_shop(sequelize, DataTypes);
  var config_skill = _config_skill(sequelize, DataTypes);
  var config_talent = _config_talent(sequelize, DataTypes);
  var config_vip = _config_vip(sequelize, DataTypes);
  var user = _user(sequelize, DataTypes);
  var user_equip = _user_equip(sequelize, DataTypes);
  var user_hero = _user_hero(sequelize, DataTypes);
  var user_item = _user_item(sequelize, DataTypes);
  var user_lineup = _user_lineup(sequelize, DataTypes);
  var user_lineup_details = _user_lineup_details(sequelize, DataTypes);
  var user_log_assets = _user_log_assets(sequelize, DataTypes);
  var user_log_gold = _user_log_gold(sequelize, DataTypes);
  var user_log_silver = _user_log_silver(sequelize, DataTypes);

  user.belongsTo(account, { as: "account", foreignKey: "account_id"});
  account.hasMany(user, { as: "users", foreignKey: "account_id"});
  config_shop.belongsTo(config_item, { as: "item", foreignKey: "item_id"});
  config_item.hasMany(config_shop, { as: "config_shops", foreignKey: "item_id"});
  auth.belongsTo(user, { as: "user", foreignKey: "user_id"});
  user.hasOne(auth, { as: "auth", foreignKey: "user_id"});
  user_equip.belongsTo(user, { as: "user", foreignKey: "user_id"});
  user.hasMany(user_equip, { as: "user_equips", foreignKey: "user_id"});
  user_hero.belongsTo(user, { as: "user", foreignKey: "user_id"});
  user.hasMany(user_hero, { as: "user_heros", foreignKey: "user_id"});
  user_item.belongsTo(user, { as: "user", foreignKey: "user_id"});
  user.hasMany(user_item, { as: "user_items", foreignKey: "user_id"});
  user_lineup.belongsTo(user, { as: "user", foreignKey: "user_id"});
  user.hasMany(user_lineup, { as: "user_lineups", foreignKey: "user_id"});
  user_log_assets.belongsTo(user, { as: "user", foreignKey: "user_id"});
  user.hasMany(user_log_assets, { as: "user_log_assets", foreignKey: "user_id"});
  user_log_gold.belongsTo(user, { as: "user", foreignKey: "user_id"});
  user.hasMany(user_log_gold, { as: "user_log_golds", foreignKey: "user_id"});
  user_log_silver.belongsTo(user, { as: "user", foreignKey: "user_id"});
  user.hasMany(user_log_silver, { as: "user_log_silvers", foreignKey: "user_id"});
  user_lineup_details.belongsTo(user_hero, { as: "hero", foreignKey: "hero_id"});
  user_hero.hasMany(user_lineup_details, { as: "user_lineup_details", foreignKey: "hero_id"});
  user_lineup_details.belongsTo(user_lineup, { as: "lineup", foreignKey: "lineup_id"});
  user_lineup.hasMany(user_lineup_details, { as: "user_lineup_details", foreignKey: "lineup_id"});

  return {
    account,
    auth,
    config_equip,
    config_exp,
    config_hero,
    config_item,
    config_shop,
    config_skill,
    config_talent,
    config_vip,
    user,
    user_equip,
    user_hero,
    user_item,
    user_lineup,
    user_lineup_details,
    user_log_assets,
    user_log_gold,
    user_log_silver,
  };
}
module.exports = initModels;
module.exports.initModels = initModels;
module.exports.default = initModels;
